#! /bin/bash


cp *.jpg /home/pi/Pictures/


sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak


cat>/etc/apt/sources.list<<EOF
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free$
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspbian.org/raspbian/ stretch main contrib non-free rpi
EOF


if ! [ -x "$(command -v fbi)" ]; then
	sudo apt update
	sudo apt install fbi -y
fi


cat>/home/pi/testboot.sh<<EOF
#!/bin/sh
sudo fbi -a /home/pi/Pictures/*.jpg -t 2 --noverbose
sudo fbi -T 1 -a /home/pi/Pictures/*.jpg -t 2 --noverbose
EOF


chmod +x /home/pi/testboot.sh


#mkdir /home/pi/.config/autostart
if [ ! -d "/home/pi/.config/autostart" ]; then
  mkdir /home/pi/.config/autostart
fi


cat>/home/pi/.config/autostart/testboot.desktop<<EOF
[Desktop Entry]
Type=Application
Name=testboot
NoDisplay=true
Exec=/home/pi/testboot.sh

EOF


# disable screen saver
cp /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.bk
sed -i '91s/#xserver-command=X/xserver-command=X -s 0 -dpms/' /etc/lightdm/lightdm.conf

